<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery-1.9.1.min.js"></script>
    <script src="../js/jquery.cookie.js"></script>
    <script>
        $(function(){
            $("#login_bth").click(function(){
                $.ajax({
                    type:"post",
                    url:"/admin/login",
                    data:$("#login_form").serialize(),
                    dataType:"json",
                    success:function(json){
                        if(json.state == 2000){
                            $("#message").text("登录成功");
                            $.cookie(
                                "token",
                                "Bearer"+json.data,
                                {"path":"/","expires":7});
                        }else{
                            $("#message").text(json.message);
                        }
                    }
                });
                return false;
            });
        });
    </script>
</head>
<body>
    <h3>用户登录</h3>
    <form id="login_form" action="" method="">
        <div>
            <label>用户名</label>
            <input  type="text" name="username"/>
        </div>
        <div>
            <label>密码</label>
            <input  type="password" name="password"/>
        </div>
        <input type="submit" id="login_bth" value="登录" />
    </form>
    <span id="message"></span>
</body>
</html>